package EstimatorPackage.Expressions;

import EstimatorPackage.Expressions.Expression;
import HierarchyPackage.HClass;

/**
 *
 * @author Martin Haulrich
 */
public class SimpleExpression implements Expression {

    public final static int type = Expression.SIMPLE;

    public final HClass c;

    public final int hash;

    public SimpleExpression(HClass c) {

        this.c = c;

        hash = 11 * c.hashCode();

    }

    @Override
    public int type() {
        return type;
    }

    @Override
    public String toString() {

        return c.getName();
    }

    @Override
    public boolean equals(Object o) {

        if (o instanceof SimpleExpression) {
            SimpleExpression se = (SimpleExpression) o;
            //         System.err.println("SimExp: " + c + " : " + se.c + "  " + c.equals(se.c));
            return (c.equals(se.c));
        }
        return false;
    }

    @Override
    public int hashCode() {

        return hash;
    }
}
